﻿namespace ContosoUniversity.DAL
{
    using System;
    using System.Linq.Expressions;
    using Models;
    using NRepository.Core.Query.Specification;

    public class FindPersonByIdSpecificationStrategy<T> : SpecificationQueryStrategy<T> where T : Person
    {
        public FindPersonByIdSpecificationStrategy(int? personId)
        {
            PersonId = personId.GetValueOrDefault();
        }

        public FindPersonByIdSpecificationStrategy(int personId)
        {
            PersonId = personId;
        }

        public int PersonId { get; }

        public override Expression<Func<T, bool>> SatisfiedBy(object additionalQueryData)
        {
            return p => p.ID == PersonId;
        }
    }
}